package com.briup.hdfs.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.hadoop.io.Writable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Apple implements Writable {
    private int id;
    private String name;
    private int age;

    @Override
    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.write(id);
        dataOutput.writeUTF(name);
        dataOutput.write(age);
    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {
        this.id = dataInput.readInt();
        this.name = dataInput.readUTF();
        this.age = dataInput.readInt();
    }
}
